//
//  AboutUsViewController.m
//  Cup
//
//  Created by dllo on 15/4/28.
//  Copyright (c) 2015年 doll. All rights reserved.
//

#import "AboutUsViewController.h"
#import "AboutUsTableViewCell.h"
#define WIDTH self.view.frame.size.width
#define HEIGHT self.view.frame.size.height
@interface AboutUsViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic, retain)UITableView *tableView;
@property(nonatomic, copy)NSString *string;
@end

@implementation AboutUsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tabBarController.tabBar.hidden = YES;
    self.string = @"在阿尔卑斯山一处风景秀美却也极为险峻的山路转弯处，经常发生事故，即使如此，来往的车辆依旧疾驰而过，不断更换的警示牌也没有起到任何作用。直到有一天那里竖起一块木牌，上面写着'慢慢走，欣赏啊'，人们才猛然惊觉，原来只记得埋头赶路，竟忘了看看这满目秀丽。\n\n人生何尝不是如此?\n\n有时我们遥望远方的山峰，却错过转弯的路口，有时我们也想屏蔽喧嚣，虽然四周车水马龙;有时我们也会厌倦忙碌，尽管路人行色匆匆。\n\n只有我们自己知道，世界有多浮躁，你的心就有多安静。\n\n当社交网络的信息越来越疯狂地涌入你的生活,你是否也想关掉它，给内心腾出一片空间，思考、书写、聆听、欣赏......\n\n这世界还有和你一样渴望宁静的人，他们正在这里，倾听时间，书写生活。\n\n请停下内心的匆忙，三人行伴你聆听世界。";
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"iconfont-fanhui"] style:UIBarButtonItemStylePlain target:self action:@selector(turnBack)];
    self.navigationItem.leftBarButtonItem.tintColor = [UIColor colorWithRed:59/255.0 green:54/255.0 blue:24/255.0 alpha:1];
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
    self.tableView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.tableView];
    [self.tableView release];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, WIDTH * 0.5333)];
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, WIDTH * 0.5333)];
    imageView.image = [UIImage imageNamed:@"coffee"];
    [self.tableView.tableHeaderView addSubview:imageView];
    [imageView release];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSDictionary *dic= [NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"Helvetica-Bold" size:18],NSFontAttributeName, nil];
    CGRect rect = [self.string boundingRectWithSize:CGSizeMake(WIDTH - 50, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return rect.size.height + WIDTH / 2.5;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *reuse = @"reuse";
    AboutUsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];
    if (!cell) {
        cell = [[AboutUsTableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuse];
    }
    cell.backgroundColor = [UIColor colorWithRed:0.470588 green:0.784314 blue:0.843137 alpha:1];
    cell.label.text = self.string;
    cell.label.textColor = [UIColor blackColor];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

- (void)dealloc
{
    [_tableView release];
    [super dealloc];
}

- (void)turnBack
{
    [self.navigationController popToRootViewControllerAnimated:YES];
    self.tabBarController.tabBar.hidden = NO;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
